#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   clean.py
@Time    :   2024/03/12 15:48:31
@Author  :   chakcy 
@Email   :   947105045@qq.com
@description   :   清理文件
'''

import os
import sys
  
def clean(folder_path, extension):
    # 使用os.walk遍历目录  
    for root, dirs, files in os.walk(folder_path):  
        for file in files:  
            if file.endswith(extension):  
                filepath = os.path.join(root, file)  
                try:  
                    # 尝试删除文件  
                    os.remove(filepath)  
                    print(f"Deleted: {filepath}")  
                except OSError as e:  
                    print(f"Error: {filepath} : {e.strerror}")  
  
    print("Done.")



if __name__ == '__main__':
    folder_path = sys.argv[1]
    extension = sys.argv[2]
    clean(folder_path, extension)